package com.bt.dmdb.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import org.hibernate.annotations.Type;
import org.joda.time.LocalDateTime;

import com.bt.dmdb.json.converter.JsonDateDeserializer;
import com.bt.dmdb.json.converter.JsonDateSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;


@Entity
@Table(name = "locations")
@SuppressWarnings("serial")
public class Locations implements java.io.Serializable{
	
	private Long id;
	private String city;
	private String country;
	private LoginUser createdBy;
	private LoginUser updatedBy;
	
	private LocalDateTime creationDate;
	
	private LocalDateTime modificationDate;	
	private CustomerDetails customerid;

	
	public Locations() {
	}

	public Locations(Long id, String city, String country,
			LoginUser createdBy, LoginUser updatedBy, LocalDateTime creationDate,
			LocalDateTime modificationDate, CustomerDetails customerid) {
		super();
		this.id = id;
		this.city = city;
		this.country = country;
		this.createdBy = createdBy;
		this.updatedBy = updatedBy;
		this.creationDate = creationDate;
		this.modificationDate = modificationDate;
		this.customerid = customerid;
	}

	@Id
    @GeneratedValue(generator = "locationsIG", strategy = GenerationType.TABLE)
    @TableGenerator(name = "locationsIG", table = "jpa_sequences", pkColumnName = "name", pkColumnValue = "Locations", allocationSize = 10, valueColumnName = "next_hi_value")
    @Column(name = "id")
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "city")
	public String getCity() {
		return city;
	}
	
	public void setCity(String city) {
		this.city = city;
	}

	@Column(name = "country")
	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	@Column(name = "creation_date")
	@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
	@JsonSerialize(using = JsonDateSerializer.class)
	@JsonDeserialize(using = JsonDateDeserializer.class)
	public LocalDateTime getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(LocalDateTime creationDate) {
		this.creationDate = creationDate;
	}

	@Column(name = "modification_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    @JsonSerialize(using = JsonDateSerializer.class)
    @JsonDeserialize(using = JsonDateDeserializer.class)
	public LocalDateTime getModificationDate() {
		return modificationDate;
	}

	public void setModificationDate(LocalDateTime modificationDate) {
		this.modificationDate = modificationDate;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "created_by")
	public LoginUser getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(LoginUser createdBy) {
		this.createdBy = createdBy;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "updated_by")
	public LoginUser getUpdatedBy() {
		return updatedBy;
	}

	public void setUpdatedBy(LoginUser updatedBy) {
		this.updatedBy = updatedBy;
	}

	@ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "customer_id")
	public CustomerDetails getCustomerid() {
		return customerid;
	}

	public void setCustomerid(CustomerDetails customerid) {
		this.customerid = customerid;
	}

	
}
